/**
 * @Author : SL
 * @Date : 2019/6/3
 * @Version :1.0
 * @Last Modified by : SL
 * @Last Modified time : 2019/6/3
 **/
const mysql = require('mysql')
const { MYSQL_CONF } = require('../conf/db')

//创建链接对象
const con = mysql.createConnection(MYSQL_CONF)

//开始链接
con.connect()

//统一执行sql语句
function exec(sql) {
    const promise=new Promise((resolve,reject)=>{
        con.query(sql,(err,result)=>{
            if (err){
                reject(err)
                return
            }
            resolve(result);
        })
    })
   return promise
}

module.exports = {
    exec
}